VERSION 5.00
Begin VB.Form frmDirType 
   Caption         =   "Select folder"
   ClientHeight    =   1428
   ClientLeft      =   60
   ClientTop       =   360
   ClientWidth     =   5232
   Icon            =   "frmDirType.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   1428
   ScaleWidth      =   5232
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton cmdDir 
      Height          =   330
      Left            =   4395
      Picture         =   "frmDirType.frx":000C
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   255
      Width           =   420
   End
   Begin VB.TextBox txtDir 
      Height          =   285
      Left            =   1065
      TabIndex        =   0
      Top             =   270
      Width           =   3225
   End
   Begin VB.PictureBox Picture1 
      Height          =   570
      Left            =   105
      ScaleHeight     =   528
      ScaleWidth      =   4920
      TabIndex        =   4
      Top             =   120
      Width           =   4965
      Begin VB.Label Label3 
         Caption         =   "Directory:"
         Height          =   210
         Left            =   120
         TabIndex        =   5
         Top             =   120
         Width           =   990
      End
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "&Cancel"
      Height          =   495
      Left            =   4080
      TabIndex        =   3
      Top             =   840
      Width           =   975
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "&OK"
      Default         =   -1  'True
      Height          =   495
      Left            =   3000
      TabIndex        =   2
      Top             =   840
      Width           =   975
   End
End
Attribute VB_Name = "frmDirType"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public strDir As String
Public blnCancel As Boolean

Private Sub cmdCancel_Click()
    blnCancel = True
    Unload Me
End Sub

Private Sub cmdDir_Click()

    On Error GoTo cmdDir_ClickFix

    If txtDir.Text <> "" Then
        If Dir(txtDir.Text, vbDirectory) <> "" Then
            '
             frmDir.Drive1.Drive = Left(txtDir.Text, 1)
             frmDir.Dir1.Path = txtDir.Text
        End If
    Else
        'frmDir.Drive1.Drive = CurDir 'application directory
        frmDir.Drive1.Drive = "C:\"
        frmDir.Dir1.Path = "C:\"
    End If
    frmDir.Show vbModal
    
    Exit Sub
    
cmdDir_ClickFix:
    If Err.Number = 52 Then
        'selected device is not available eg e:\
        frmDir.Drive1.Drive = "C:\"
        frmDir.Dir1.Path = "C:\"
    Else
        MsgBox "cmdDir_Click: " & Err.Number & " - " & Err.Description, vbExclamation, "Directory Clean Up"
    End If
End Sub

Private Sub cmdOK_Click()
    
    Dim strDirExists As String
    Dim strAnswer As String
    
    On Error GoTo cmdOkFix
        
    'CHECK IF DIR EXISTS, ELSE CREATE?
    If Dir(txtDir.Text, vbDirectory) = "" Then
        If Dir(txtDir.Text, vbDirectory) = "" Then
            strAnswer = MsgBox("This directory does not exist. Do you want create it?", vbYesNo, "Directory Clean Up")
            If strAnswer = vbYes Then
                MkDir txtDir.Text
            Else
                txtDir.SetFocus
                Exit Sub
            End If
        End If
    Else
        If Right(txtDir.Text, 1) <> "\" Then
            txtDir.Text = txtDir.Text & "\"
        End If
    End If
    If Len(txtDir.Text) > 1 Then
        strDir = txtDir.Text
    Else
        txtDir.Text = ""
    End If
    'Me.Hide
    Unload Me
    
    Exit Sub
    
cmdOkFix:
    MsgBox "cmdOk: " & Err.Number & " - " & Err.Description, vbExclamation, "Directory Clean Up"
End Sub


Private Sub Form_Activate()
    txtDir.SetFocus
    Screen.MousePointer = vbDefault
End Sub

Private Sub Form_Load()

'    Dim i As Integer

    On Error GoTo FormDir_LoadFix

    blnCancel = False
    
'    If strDir <> "" Then
        txtDir.Text = strDir
'    Else
'        txtDir.Text = "C:\"
'    End If
    
    Exit Sub
    
FormDir_LoadFix:
    'MsgBox "FormDir_Load: " & Err.Number & " - " & Err.Description, vbExclamation, "Directory Clean Up"
'    WriteFile Now & "FormDir_Load: " & Err.Number & " - " & Err.Description & Now, strErrFile
'    If frmSettings.picError.Visible = False Then
'        frmSettings.picError.Visible = True
'    End If
End Sub



Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Screen.MousePointer = vbHourglass
End Sub

Private Sub txtDir_GotFocus()
    txtDir.SelStart = 0
    txtDir.SelLength = Len(txtDir.Text)
End Sub

Private Sub txtDir_LostFocus()

        If frmDirType.ActiveControl.Name <> "cmdCancel" Then
        'DIRECTORY MAY BE NULL IF SCREEN IS CANCELLED
            If txtDir.Text = "" Then
                If frmDirType.ActiveControl.Name <> "cmdDir" Then
                    Beep
                    txtDir.SetFocus
                End If
            End If
        End If
End Sub

